package com.jiazhong.backend.test;


import com.jiazhong.backend.service.UserService;
import com.jiazhong.commons.bean.User;
import jakarta.annotation.Resource;
import lombok.extern.slf4j.Slf4j;
import org.junit.jupiter.api.Test;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.stereotype.Component;


import java.util.List;

@SpringBootTest
@Component
@Slf4j
public class UserApp {
    @Resource
    private UserService service;

    //查询全部
    @Test
    public void a(){
        List<User> list = service.list();
        list.forEach(System.out::println);
    }
    //新增数据
    @Test
    public void b(){
        User user = new User();
        user.setUsername("猪不减肥");
        user.setPhone("123456897");
        user.setPassword("123456");
        service.save(user);
    }
    //删除数据
    @Test
    public void c(){
        boolean removeById = service.removeById("1853272783843540993");
        log.info("removeById:{}",removeById);
    }

    //修改信息
    @Test
    public void d(){
        User user = new User();
        user.setId("1853273341102956546");
        user.setUsername("猪减不减肥");
        boolean updateById = service.updateById(user);
    }
}
